/*
* 是否为空对象
* */

export default {
  /*
    * 空判断
    * */
  isEmpty(obj) {
    if (!obj && obj !== 0 && obj !== '') {
      return true;
    }
    if (Array.prototype.isPrototypeOf(obj) && obj.length === 0) {
      return true;
    }
    if (Object.prototype.isPrototypeOf(obj) && Object.keys(obj).length === 0) {
      return true;
    }
    return false;
  },

  /*
   * 对象复制
   * */

  cloneObject(obj) {
    return JSON.parse(JSON.stringify(obj))
  },

  /*
  * 初始化权限
  * */
  getPermission(pageId){
    let obj={isViewShow:false,isViewEdit:false}
    let arry = JSON.parse(sessionStorage.getItem("quanXian"))
    for(let i = 0;i<arry.length;++i) {
      if (arry[i].id === pageId) {
        if (arry[i].isSee === 1) {
          obj.isViewShow = true
        } else {
          obj.isViewShow = false
        }

        if (arry[i].isOperate === 1) {
          obj.isViewEdit = true
        } else {
          obj.isViewEdit = false
        }
        break
      }

      for (let j = 0; j < arry[i].subPages.length; ++j) {
        if (arry[i].subPages[j].id === pageId) {
          if (arry[i].subPages[j].isSee === 1) {
            obj.isViewShow = true
          } else {
            obj.isViewShow = false
          }

          if (arry[i].subPages[j].isOperate === 1) {
            obj.isViewEdit = true
          } else {
            obj.isViewEdit = false
          }
          break
        }
      }
    }
    return obj
  },

}




